<?
/*
**燕塞湖检票通知同步程序
**2015-06-
**by pzp
*/
// $txt=json_encode($_REQUEST);
// logfile(date('Y-m-d H:i:s').'---'.$txt);

include_once('/var/www/html/new/d/module/api/function.class.php');
if (!class_exists("go_sql")){
	include("/var/www/html/new/conf/le.je");
	$le=new go_sql();
	$le->connect();
}
$PFT_infunction = new AllFunction();
$txt = '{"pcode":"380815","checktime":"2015-07-23 11:07:20","num":"8","sign":"22E061AF9EFB53BE08DA275AB27C376C"}';
if($txt){
	$arr = json_decode($txt,true);
	$sign = $arr['sign'];
	$pcode = $arr['pcode'];
	$checktime = $arr['checktime'];
	$ysh_num = $arr['num'];
	$check_sign = strtoupper(md5("check:".$pcode));
	if($sign == $check_sign){
		$inSide = new SoapClient(null,array(
			"location" => "http://localhost/open/openService/pft_insideMX.php",
			"uri" => "www.16u.com?ac_16u=16ucom|pw_16u=c33367701511b4f6020ec61ded352059|auth_16u=true")
		);
		$ysh_pcode = 'ysh_'.$pcode;
		$pft_order = $inSide->Order_Globle_Search(
				0,0,0,0,"",
				"","","","","",
				"","","","",0,
				"","","",1,0,
				0,1,0,"","",
				"",$ysh_pcode,"","","",
				"","","","",""
		);
		if(strlen($pft_order)>50){
			$pft_order_xml =simplexml_load_string($pft_order);
			// print_r($pft_order_xml);
			$UUcode = (string)$pft_order_xml->Rec->UUcode;
			$UUtnum = (string)$pft_order_xml->Rec->UUtnum;
			$UUsalerid = (string)$pft_order_xml->Rec->UUsalerid;
			$UUstatus = (string)$pft_order_xml->Rec->UUstatus;
			// echo 	$UUsalerid."-".$UUcode;exit;
			if($UUstatus == 0 && $UUtnum == $ysh_num){
				$terminal = $PFT_infunction->Compatible_Check_IN($UUsalerid,$UUcode,date('Y-m-d H:i:s'));
				if($terminal == 100){
					echo "验证成功";
				}else{
					logfile($ysh_pcode."->".$terminal);
					echo "验证失败";			
				}
			}else{
				echo "订单不是未使用状态";
			}
		}
		else{
			echo "未找到订单";
		}
	}
	else{
		echo "校验不通过";
	}
}
else{
	echo "无接收任何数据";
}

function logfile($txt){
	$fp = fopen('/var/www/html/new/d/module/api/YanSaiHu/ysh_check.txt',"a");
	flock($fp, LOCK_EX) ;
	fwrite($fp,$txt."\n");
	flock($fp, LOCK_UN);
	fclose($fp); 
}
?>